'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:FinanceFZjfyCtrl
 * @description
 * # FinanceFZjfyCtrl
 * Controller of the jgappApp
 */
angular.module('jgappApp')
    .controller('FinanceFZjfyCtrl', function ($scope, DataService, $rootScope, openApi, Util, $location, $routeParams, FormSubmit) {
        var id = $scope.process_id = $routeParams.id
        $scope.chooseinfo = function () {
            var relModuleObj = {
                name: "FinanceFZjfyCtrl",
                selectTab: "select_agreement_apply_by_cost",
                selectTabContent: "合同编号"
            };
            // 清掉关联的编号
            var params = $scope.param;
            Util.savaParamForReview(params, id);
            Util.savaDataforsearch(relModuleObj);
            $location.path("finance/choosepeople")
        };
        $scope.submit = function (operationId) {

            // 底部类型end
            var options = {};
            // 流程id
            options.id = id;
            // 根据operationId判断是草稿还是提交
            options.operationId = operationId;
            options.urlParam = openApi.certificateCost;
            options.param = angular.copy($scope.param, {});
            FormSubmit.submit(options,$scope);
        };
        $scope.validate = function () {
            if (!$scope.param.contractNo) {
                Util.Toast("请选择证件编号");
                return;
            }
            if (!$scope.param.curentPayDate) {
                Util.Toast("请选择本次支付使用开始时间");
                return;
            }
            if (!$scope.param.nextPayDateNew) {
                Util.Toast("请选择本次支付使用结束时间");
                return;
            }
            if (!$scope.param.currentPayAmount) {
                if ($scope.param.currentPayAmount !== 0) {
                    Util.Toast("请填写本次支付金额");
                    return;
                }
            }
            if (!$scope.validation.passvalidation) {
                Util.Toast($scope.validation.tip);
                return;
            }
            return true;
        }
        var init = function () {
            // 获取回显的详细信息
            Util.getDetailData(id, function (data) {
                $scope.param = data;
            });
        };
        // 初始化
        init();
    });